//页面初始化
mui.init();
var phone;
var mobile;
//设置新密码
$(document).on('tap', '#forget_pwd_btn', function() {
	var new_pass = $("#new_pwd").val(); //新密码
	var again_new_pass = $("#again_new_pwd").val(); //新密码
	var pwdRerg = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,15}$/; //正则验证 
	if(!new_pass) {
		mui.alert("新密码不能为空");
		return false;
	}
	if(!again_new_pass) {
		mui.alert("确认密码不能为空");
		return false;
	}
	if(new_pass!=again_new_pass) {
		mui.alert("新密码与确认密码不一致！");
		return false;
	}
//	if(!pwdRerg.test(new_pass)) {
//		mui.alert("密码格式不正确");
//		$("#new_pwd").val("");
//		return false;
//	}
	console.log(new_pass);
	console.log(phone);
	mui.ajax(user_url + '/api/user/editPassword', {
		data: {
			"new_password": new_pass,
			"phone": phone,
			"sign": "string",
			"user_id": ""
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		success: function(data) {
			console.log(JSON.stringify(data));
			if(data.code == 10000) {
				mui.alert("新密码设置成功", function() {
					window.top.location.href = "../user/login.html"
				})
			} else {
				mui.alert(data.msg)
			}
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	});
})
//页面进入执行方法
window.onload = function() {
	mui.plusReady(function() {
		self = plus.webview.currentWebview();
		phone = self.phone;
	});
}